package com.heyqing.topic.ContainsDuplicate_0217;


import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * ClassName:ContainsDuplicate
 * Package:com.heyqing.topic.ContainsDuplicate_0217
 * Description:
 *
 * @Date:2024/9/22
 * @Author:Heyqing
 */
public class ContainsDuplicate {
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        int lastSize = 0;
        for (int i = 0; i < nums.length; i++) {
            set.add(nums[i]);
            if (lastSize == set.size()) return true;
            lastSize = set.size();
        }
        return false;
    }
}
